{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.3 64-bit",
   "metadata": {
    "interpreter": {
     "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'北京婚纱照怦然心动的民国复古婚纱照想拍同款婚纱照，点击上方立即咨询喔建议收藏和点小心心长期关注我，每天看最新风格样片客片关键词：民国复古怀旧拍摄：玫瑰星座有一种创新叫做复古每一个时代都写满了故事岁月在变年岁在长那个时代的余韵绕梁每次听见老电影里温柔婉转的歌声起仿佛又回到那个全世界都变得纯情的年代复制了民国年代的婚纱照，暖融融的色调，胶片质感特有的模糊颗粒感的机理就想来电影的屏幕走出来，BGM是甜蜜蜜干净舒适的妆面，拍摄自带复古滤镜的婚纱照获取报价咨询婚纱照关注夏洛克婚纱摄影工作室扣1即可。北京婚纱照深圳婚纱照森系婚纱照纪实婚纱照森系婚纱照简约婚纱照美好婚纱照文艺婚纱照浪漫婚纱照胶片婚纱照北京婚纱摄影北京婚纱摄影深圳婚纱摄影婚纱照风格推荐婚纱照工作室婚纱照客片北京婚纱照深圳婚纱照上海婚纱照保定廊坊重庆山西天津河北深圳株洲惠州珠海东莞复古民国复古民国复古北京婚纱照旗袍民国民国北京婚纱照旗袍北京婚纱照'"
      ]
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "\n",
    "def filter_str(desstr, restr=''):\n",
    "    # 过滤除中英文及数字以外的其他字符\n",
    "    res = re.compile(\"[^\\\\u4e00-\\\\u9fa5^a-z^A-Z^0-9,.，。:：]\")\n",
    "    return res.sub(restr, desstr)\n",
    "filter_str(\"\"\"北京婚纱照|怦然心动的民国复古婚纱照� 想拍同款婚纱照，点击上方⬆️<立即咨询>喔 建议收藏和点小心心� 长期关注我，每天看最新风格样片、客片 ———————————— 关键词：民国 复古 怀旧 拍摄： @玫瑰星座 - � 有一种创新叫做“复古” 每一个时代都写满了故事 岁月在变、年岁在长 - � 那个时代的余韵绕梁 每次听见老电影里温柔婉转的歌声起 仿佛又回到那个全世界都变得纯情的年代 - � 复制了民国年代的婚纱照， 暖融融的色调，胶片质感特有的模糊颗粒感的机理 就想来电影的屏幕走出来，BGM是甜蜜蜜 干净舒适的妆面，拍摄自带复古滤镜的婚纱照 - ———————————— 《获取报价//咨询婚纱照 关注 @夏洛克婚纱摄影工作室 扣“1”即可。》 北京婚纱照 深圳婚纱照 森系婚纱照 纪实婚纱照 森系婚纱照 简约婚纱照 美好婚纱照 文艺婚纱照 浪漫婚纱照 胶片婚纱照 北京婚纱摄影 北京婚纱摄影 深圳婚纱摄影 婚纱照风格推荐 婚纱照工作室 婚纱照客片 北京婚纱照 深圳婚纱照 上海婚纱照 保定 廊坊 重庆 山西 天津 河北 深圳 株洲 惠州 珠海 东莞 复古民国复古民国复古北京婚纱照旗袍民国民国北京婚纱照旗袍北京婚纱照\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "[['站了个早', '正常', nan]]\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "data = pd.read_csv('data.csv')\n",
    "data = data.values.tolist()\n",
    "\n",
    "res = pd.read_csv('res_001.csv')\n",
    "res = res.values.tolist()\n",
    "print(res[:1])\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "621843\n626720\n"
     ]
    }
   ],
   "source": [
    "rev_data_key_map = { filter_str(val[0])[:]:val[0] for val in data}\n",
    "data_key_map = { val[0]:filter_str(val[0])[:] for val in data}\n",
    "rev_res_key_map = {filter_str(val[0])[:]:val[0] for val in res}\n",
    "rev_res_map = {filter_str(val[0]):val for val in res}\n",
    "\n",
    "print(len(rev_res_key_map))\n",
    "print(len(data_key_map))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "data_res 626720\n"
     ]
    }
   ],
   "source": [
    "data_res = []\n",
    "\n",
    "for item in data:\n",
    "    default_item = [item[0],'正常','']\n",
    "    key = data_key_map[item[0]]\n",
    "    data_res_item = rev_res_map.get(key, default_item)\n",
    "    data_res.append(data_res_item)\n",
    "    # print('data_res_item', data_res_item)\n",
    "\n",
    "print('data_res', len(data_res))\n",
    "\n",
    "# aa = set(rev_data_key_map.keys()) \n",
    "# bb = set(rev_res_key_map.keys())\n",
    "# aa = [ii for ii in aa if '宜居三房' in ii]\n",
    "# bb = [ii for ii in bb if '宜居三房' in ii]\n",
    "# print(aa)\n",
    "# print(bb)\n",
    "# print(aa[0] == bb[0])\n",
    "\n",
    "# for ii, val in enumerate(aa[0]):\n",
    "#     if val != bb[0][ii]:\n",
    "#         print(val)\n",
    "\n",
    "\n",
    "\n",
    "# diff = set(rev_data_key_map.keys()) - set(rev_res_key_map.keys())\n",
    "# print(len(diff))\n",
    "# print(list(diff)[:2])\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "pres = pd.DataFrame(data_res)\n",
    "\n",
    "pres.to_csv('aa.csv')"
   ]
  }
 ]
}